This application includes subject matter protected by copyright. All rights are reserved.
1. Technical Field
This invention relates generally to database management. In particular, this invention relates to methods for mapping data between an object-oriented data model and a relational data model.
2. Description of the Related Art
A relational database management system (RDBMS) is a computer database management system that uses relational techniques for storing and retrieving data. Relational databases are computerized information storage and retrieval systems in which data in the form of tables (or relations) are typically stored for use on disk drives or similar mass datastores. A table includes a set of rows (or records) spanning several columns. Each column in a table typically includes restrictions on the data contents thereof. An RDBMS is structured to accept commands to store, retrieve and delete data using high-level query languages such as the Structured Query Language (SQL). A query denotes a set of commands for retrieving data from a stored database.
Object-oriented programming methodologies are also well-known in the prior art. Such methods focus on manipulating data rather than procedures. In an object-oriented paradigm, objects encapsulate related data and procedures to hide that information from the remainder of the program by allowing access to the data and procedures only through the object""s interface. Thus, changes to the data or procedures of the object are relatively isolated from the remainder of the program.
An object-oriented computing environment typically includes an object-oriented database for storing data according to an object-oriented database schema. The object-oriented database schema specifies the information needed to define the classes and class hierarchy for the objects stored in the object-oriented database, such as the attributes for each class, the data type of each attribute, and the like. A given object may be transient or persistent. A persistent object is an object whose state can outlive the life of a specific instance of the object.
An object-oriented environment may be distributed across computers interconnected by a computer network. A distributed object refers to an encapsulated package of code and data that can be manipulated by operations through an interface. Distributed objects can be located anywhere in a network as clients or servers, depending upon whether they are sending requests to other objects or replying to requests from clients.
Given the popularity of relational databases as well the widespread implementation of object-oriented programming methods, it has become necessary to provide tools by which object-oriented applications can fetch data from relational databases. In response, the prior art has developed several different approaches to this problem. In one approach, as represented in U.S. Pat. Nos. 5,761,671, 5,794,247 and 5,794,248, to Blackman et al., commonly assigned to IBM, a bridge is used to translate data between object-oriented and non-object-oriented datastores. The bridge provides a datastore persistent object class to wrap or encapsulate data retrieved from the relational database, a queryable persistent identifier to specify information used to locate the data in the relational database needed to populate a given object, and a schema mapper class used to obtain the required data from the relational database and to translate or transfer it into the format of the particular requesting object.
Another approach to this problem is illustrated in U.S. Pat. No. 5,765,159, to Srinivasan, also assigned to IBM. This patent provides a method for processing object-oriented queries to retrieve data from a relational database. An object-oriented query and at least one prefetch path are received from an object-oriented program. The prefetch path identifies one or more objects that are desired to be constructed. The query is translated to a translated object query, which is a relational database query capable of retrieving from the RDBMS data to initialize base attributes of top-level objects identified by the query. A set of relational queries is generated from the translated object query and the prefetch path. These relational queries are processed by the RDBMS.
Still other approaches to the problem of mapping data between a relational format and an object-oriented format are described in several patents, including, U.S. Pat. No. 5,694,598 to Durand et al., U.S. Pat. No. 5,499,371 to Henninger et al., U.S. Pat. No. 5,734,887 to Kingberg et al., to name just a few. In Durand et al., which is a distributed object operating environment, the invention uses a special construct, a so-called transit object, for this purpose. In Henninger et al., the relational database interaction is controlled directly by the methods of the object class, e.g., using embedded SQL. Kingberg et al. use a logical data access layer to access the physical structure of a relational database.
Although the above-described patents all provide useful techniques for enabling object-oriented access to a relational database, there remains a need in the art to provide a persistent object service (POS) that can interface with all of the major different types of relational databases including, for example, Oracle, Sybase, MS-SQL Server, Informix and DB2. The present invention addresses this need in the art.
It is a general feature of the invention to map data between an object-oriented format and a relational format.
It is another general feature of this invention to provide a generic persistent object service (POS) that may interface to different and varied relational database management systems.
Another general feature of this invention is to map objects to one or more tables in a relational database based on the object""s attribute types.
Still another feature of this invention to provide a novel mechanism for storing an object in a relational database, and for restoring that object from data retrieved from that database.
These and other features of the present invention are provided in a persistent object service (POS) that interfaces to a set of one or more relational database management systems. A persistent object, namely, an object whose state may outlive the life of a specific instance of the object, is mapped to one or more tables in a relational database based on the object""s attribute types and the object""s relationships with other objects. If the object inherits from another object, the mapping creates multiple tables, a top level table for base attributes, and a set of one or more child tables that contain extended attributes of the inherited objects. The service includes an object store routine for storing an object by converting persistent object operations to a sequence of SQL statements. The service also includes an object restore routine for re-generating the object by retrieving object attribute information from the relational tables.
The foregoing has outlined some of the more pertinent objects and features of the present invention. These objects should be construed to be merely illustrative of some of the more prominent features and applications of the invention. Many other beneficial results can be attained by applying the disclosed invention in a different manner or modifying the invention as will be described. Accordingly, other objects and a fuller understanding of the invention may be had by referring to the following Detailed Description of the Preferred Embodiment.